import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


import java.lang.*;
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class SillyStateChange extends MIDlet implements ItemStateListener {
  Display display;
  Form frm;
  TextField text;

  public SillyStateChange () {
    frm = new Form ("Silly");
    text = new TextField("","",20,TextField.ANY);
    frm.setItemStateListener(this);
    frm.append(text);
  }
  public void startApp() {
    if(display==null) {
      display = Display.getDisplay (this);
    }
    display.setCurrent (frm);
  }
  public void itemStateChanged(Item x) {
    if(x==text) {
      System.out.println("text changed, now: "+text.getString());
    }
  }
  public void pauseApp() {  }
  public void destroyApp(boolean unconditional) {  }

}
